-
-
Notifications
You must be signed in to change notification settings - Fork 214
Add php validator reference #30
Conversation
I'm a bit out of PHP land now, but have you looked at BCMath? Regardless, I'll accept. |
@Relequestual, thanks for the merge. I did look at BCMath but it won't help in this case. The fact is PHP doesn't know big nums. If one of these is encountered when parsing json data using the standard I guess if big num support was an absolute requirement, you could build your own PS: I see one PHP validator passing the whole test suite, but it relies on a string conversion trick that make its behaviour incorrect in some cases. |
Interesting! Makes it behave incorrectly in some cases? Any idea which cases? (Because those should be added to the test suite... right?) At least it tries to do the right thing |
Maybe you could warn, and allow the application to handle those intsnaces. Throwing thoughts at the wall on this one. I'm annoyed / dissapointed at this problem (of json-schema), give how much flak I give swagger for similar validation issues. =/ |
@awwright Any thoughts on this? (not the PR, but the discussion) |
I agree. If I'm not mistaken, the implementation mentionned above will report that instance: "12345678910111213141516171819202122232425262728293031" valid against that schema: { "type": "integer" } instead of reporting a type mismatch error (string vs expected integer).
It's not like I didn't try to do something about it. I just think we hit a PHP limitation here. I thought that the |
It's even more tricky in perl land =D |
@stefk @Relequestual Technically, JSON Schema describes application/json documents, the string of bytes before it gets parsed into any data structure. If the JSON Schema library is itself using Virtually everyone tests against an in-memory structure, though. It's not that big of an issue, as long as the result would be the same as |
Having slept on this discussion, I consider that, if a languge handles some JSON structure in one way when decoding, and that's the standard way, then I feel that's fine. A library will validate the sturcture as far as the language in use understands it. I see your point about validation before it gets parsed, but that sort of also doesn't make sense. I mean, you HAVE to parse the JSON in order to read it, at all. |
Thank you both for your input! I think we all agree that pragmatism is needed on that issue, and that fighting the language default tooling and data structures isn't probably worth it ;) |
It's a tricky one for sure. I had some similar instances with Perl. I won in the end ;) |
https://github.com/stefk/JVal